package com.wjw;

import com.wjw.model.User;
import com.wjw.utils.HibernateUtil;
import org.hibernate.Query;
import org.hibernate.Session;
import org.junit.Test;

import java.util.List;


public class testHql {

    @Test
    public void test(){
        Session session= HibernateUtil.getSession();
        //String hql="from User where name=:name";
        String hql="from User where name=? or id=?";
        Query query=session.createQuery(hql);
        //query.setString("name","xiaoming");
        query.setString(0,"xiaoming");
        query.setString(1,"2");
        List<User> userList=query.list();

        for(User user:userList){
            System.out.println(user.getName()+"------"+user.getNumber());
        }
    }
}
